
var isApp = () => {
    return window.plus ? true : false
}
var getItem = function(key){
    return isApp() ? window.plus.storage.getItem(key) :  window.localStorage.getItem(key)
}
var setItem = function(key, val){
    isApp() ? window.plus.storage.setItem(key, val + '') :  window.localStorage.setItem(key, val + '')
}
var removeItem = function(key){
    isApp() ? window.plus.storage.removeItem(key) :   window.localStorage.removeItem(key)
}
var _clear = function(){
    isApp() ? window.plus.storage.clear() : window.localStorage.clear()
}

export const setToken = token => {
    setItem("token", token);
}

export const removeToken = () => {
    removeItem("token");
}

export const getToken = () => {
    return getItem("token");
}

export const setuserUid = userUid => {
    setItem("userUid", userUid);
}


export const removeuserUid = () => {
    removeItem("userUid");
}

export const getuserUid = () => {
    return getItem("userUid");
}

// app角色
export const setRole = role => {
    setItem("role", role);
}

export const getRole = () => {
    return getItem("role");
}

export const removeRole = () => {
    removeItem("role");
}

// 登录详情 userLogin
export const setUserLogin = userLogin => {
   setItem("userLogin",JSON.stringify(userLogin) );
}

export const getUserLogin = () => {
    return JSON.parse(getItem("userLogin"))
}

// 登录设置 查询设置新版本
export const setVersionNo = versionNo => {
    setItem("versionNo",JSON.stringify(versionNo) );
}

export const getVersionNo = () => {
    return JSON.parse(getItem("versionNo"))
}

// 个人中心 -我的资料
export const setUserInfo = userInfo => {
    setItem("userInfo",JSON.stringify(userInfo) );
}

export const getUserInfo = () => {
    return JSON.parse(getItem("userInfo"))
}

export const removeUserInfo = () => {
    removeItem("userInfo");
}

// 记住密码（用于登录环信）
export const setPassword = password => {
    setItem("password", password);
}
export const getPassword = () => {
    return getItem("password");
}
export const removePassword = () => {
    removeItem("password");
}

export const clear = () => {
    _clear()
}